<template>
	<div>
	    <div class="crumbs">
	        <el-breadcrumb separator="/">
	            <el-breadcrumb-item>
	                <i class="el-icon-lx-cascades"></i> 优秀干事评选
	            </el-breadcrumb-item>
	        </el-breadcrumb>
	    </div>
		
		<div class="block">
		  <span class="demonstration">选择部门干事：</span>
		  <el-cascader
		    ref="myCascader"
		    v-model="value"
		    :options="options"
		    @change="handleChange"></el-cascader>
		</div>
		
		<div class="el-table__empty-block">
			<span class="title-name">工作方面: </span>
			<v-rate v-model="valueA1"
			show-text
			text-type="number"
			text-template="{value}分"
			:size="23" :allow-half="true" :max="10"></v-rate>
		</div>	
		<div class="el-table__empty-block">
			<span class="title-name">学习方面: </span>
			<v-rate v-model="valueA2"
			show-text
			text-type="number"
			text-template="{value}分"
			:size="23" :allow-half="true" :max="10"></v-rate>
		</div>	
		<div class="el-table__empty-block">
			<span class="title-name">生活方面: </span>
			<v-rate v-model="valueA3"
			show-text
			text-type="number"
			text-template="{value}分"
			:size="23" :allow-half="true" :max="10"></v-rate>
		</div>	
		<div class="el-table__empty-block">
			<span class="title-name">志愿方面: </span>
			<v-rate v-model="valueA4"
			show-text
			text-type="number"
			text-template="{value}分"
			:size="23" :allow-half="true" :max="10"></v-rate>
		</div>	
		<div class="el-table__empty-block">
			 <el-button type="primary" @click="commitEdit()">提交</el-button>
		</div>	
		
		
		
		
		
	</div>
</template>

<script>
import rate from "../common/Rate.vue"
import '../../styles/less/index.less'
export default{
	data(){
		return{
			rate,
			valueA1: 0,
			valueA2: 0,
			valueA3: 0,
			valueA4: 0,
			value: [],
			options: [{
			  value: '0',
			  label: '宣传部',
			  children: [{
				value: '201441404241',
				label: '郭进贵'
				},{
				value: '201441404242',
				label: '任宏博'
				},{
				value: '201441404243',
				label: '邵成宽'
				},{
				value: '201441404244',
				label: '周杰伦'
				},{
				value: '201441404245',
				label: '陈奕迅'
				},{
				value: '201441404246',
				label: '谢霆锋'
				},{
				value: '201441404247',
				label: '林俊杰'
				},{
				value: '201441404248',
				label: '尊龙'
			   }]
			  },
			{
			  value: '1',
			  label: '组织部',
			  children: [{
				value: '201441404241',
				label: '郭进贵'
				},{
				value: '201441404242',
				label: '任宏博'
				},{
				value: '201441404243',
				label: '邵成宽'
				},{
				value: '201441404244',
				label: '周杰伦'
				},{
				value: '201441404245',
				label: '陈奕迅'
				},{
				value: '201441404246',
				label: '谢霆锋'
				},{
				value: '201441404247',
				label: '林俊杰'
				},{
				value: '201441404248',
				label: '尊龙'
			   }]
			  },
		    {
			  value: '2',
			  label: '外联部',
			    children: [{
			  	value: '201441404241',
			  	label: '郭进贵'
			  	},{
			  	value: '201441404242',
			  	label: '任宏博'
			  	},{
			  	value: '201441404243',
			  	label: '邵成宽'
			  	},{
			  	value: '201441404244',
			  	label: '周杰伦'
			  	},{
			  	value: '201441404245',
			  	label: '陈奕迅'
			  	},{
			  	value: '201441404246',
			  	label: '谢霆锋'
			  	},{
			  	value: '201441404247',
			  	label: '林俊杰'
			  	},{
			  	value: '201441404248',
			  	label: '尊龙'
			   }]
			 },
			 {
			   value: '3',
			   label: '秘书处',
			     children: [{
			   	value: '201441404241',
			   	label: '郭进贵'
			   	},{
			   	value: '201441404242',
			   	label: '任宏博'
			   	},{
			   	value: '201441404243',
			   	label: '邵成宽'
			   	},{
			   	value: '201441404244',
			   	label: '周杰伦'
			   	},{
			   	value: '201441404245',
			   	label: '陈奕迅'
			   	},{
			   	value: '201441404246',
			   	label: '谢霆锋'
			   	},{
			   	value: '201441404247',
			   	label: '林俊杰'
			   	},{
			   	value: '201441404248',
			   	label: '尊龙'
			    }]
			  },
			  {
			    value: '4',
			    label: '志愿站',
			      children: [{
			    	value: '201441404241',
			    	label: '郭进贵'
			    	},{
			    	value: '201441404242',
			    	label: '任宏博'
			    	},{
			    	value: '201441404243',
			    	label: '邵成宽'
			    	},{
			    	value: '201441404244',
			    	label: '周杰伦'
			    	},{
			    	value: '201441404245',
			    	label: '陈奕迅'
			    	},{
			    	value: '201441404246',
			    	label: '谢霆锋'
			    	},{
			    	value: '201441404247',
			    	label: '林俊杰'
			    	},{
			    	value: '201441404248',
			    	label: '尊龙'
			     }]
			   },
			   {
			     value: '5',
			     label: '办公室',
			       children: [{
			     	value: '201441404241',
			     	label: '郭进贵'
			     	},{
			     	value: '201441404242',
			     	label: '任宏博'
			     	},{
			     	value: '201441404243',
			     	label: '邵成宽'
			     	},{
			     	value: '201441404244',
			     	label: '周杰伦'
			     	},{
			     	value: '201441404245',
			     	label: '陈奕迅'
			     	},{
			     	value: '201441404246',
			     	label: '谢霆锋'
			     	},{
			     	value: '201441404247',
			     	label: '林俊杰'
			     	},{
			     	value: '201441404248',
			     	label: '尊龙'
			      }]
			    },
				{
				  value: '6',
				  label: '文体部',
				    children: [{
				  	value: '201441404241',
				  	label: '郭进贵'
				  	},{
				  	value: '201441404242',
				  	label: '任宏博'
				  	},{
				  	value: '201441404243',
				  	label: '邵成宽'
				  	},{
				  	value: '201441404244',
				  	label: '周杰伦'
				  	},{
				  	value: '201441404245',
				  	label: '陈奕迅'
				  	},{
				  	value: '201441404246',
				  	label: '谢霆锋'
				  	},{
				  	value: '201441404247',
				  	label: '林俊杰'
				  	},{
				  	value: '201441404248',
				  	label: '尊龙'
				   }]
				 },
				 {
			  value: '7',
			  label: '学习部',
			    children: [{
			  	value: '201441404241',
			  	label: '郭进贵'
			  	},{
			  	value: '201441404242',
			  	label: '任宏博'
			  	},{
			  	value: '201441404243',
			  	label: '邵成宽'
			  	},{
			  	value: '201441404244',
			  	label: '周杰伦'
			  	},{
			  	value: '201441404245',
			  	label: '陈奕迅'
			  	},{
			  	value: '201441404246',
			  	label: '谢霆锋'
			  	},{
			  	value: '201441404247',
			  	label: '林俊杰'
			  	},{
			  	value: '201441404248',
			  	label: '尊龙'
			   }]
			 },
			 {
			  value: '8',
			  label: '师友电脑维修部',
			    children: [{
			  	value: '201441404241',
			  	label: '郭进贵'
			  	},{
			  	value: '201441404242',
			  	label: '任宏博'
			  	},{
			  	value: '201441404243',
			  	label: '邵成宽'
			  	},{
			  	value: '201441404244',
			  	label: '周杰伦'
			  	},{
			  	value: '201441404245',
			  	label: '陈奕迅'
			  	},{
			  	value: '201441404246',
			  	label: '谢霆锋'
			  	},{
			  	value: '201441404247',
			  	label: '林俊杰'
			  	},{
			  	value: '201441404248',
			  	label: '尊龙'
			   }]
			 },
			 {
			  value: '9',
			  label: '自律部',
			    children: [{
			  	value: '201441404241',
			  	label: '郭进贵'
			  	},{
			  	value: '201441404242',
			  	label: '任宏博'
			  	},{
			  	value: '201441404243',
			  	label: '邵成宽'
			  	},{
			  	value: '201441404244',
			  	label: '周杰伦'
			  	},{
			  	value: '201441404245',
			  	label: '陈奕迅'
			  	},{
			  	value: '201441404246',
			  	label: '谢霆锋'
			  	},{
			  	value: '201441404247',
			  	label: '林俊杰'
			  	},{
			  	value: '201441404248',
			  	label: '尊龙'
			   }]
			 },
			 {
			  value: '10',
			  label: '网络技术部',
			    children: [{
			  	value: '201441404241',
			  	label: '郭进贵'
			  	},{
			  	value: '201441404242',
			  	label: '任宏博'
			  	},{
			  	value: '201441404243',
			  	label: '邵成宽'
			  	},{
			  	value: '201441404244',
			  	label: '周杰伦'
			  	},{
			  	value: '201441404245',
			  	label: '陈奕迅'
			  	},{
			  	value: '201441404246',
			  	label: '谢霆锋'
			  	},{
			  	value: '201441404247',
			  	label: '林俊杰'
			  	},{
			  	value: '201441404248',
			  	label: '尊龙'
			   }]
			 },
			 {
			  value: '11',
			  label: '辩论队',
			    children: [{
			  	value: '201441404241',
			  	label: '郭进贵'
			  	},{
			  	value: '201441404242',
			  	label: '任宏博'
			  	},{
			  	value: '201441404243',
			  	label: '邵成宽'
			  	},{
			  	value: '201441404244',
			  	label: '周杰伦'
			  	},{
			  	value: '201441404245',
			  	label: '陈奕迅'
			  	},{
			  	value: '201441404246',
			  	label: '谢霆锋'
			  	},{
			  	value: '201441404247',
			  	label: '林俊杰'
			  	},{
			  	value: '201441404248',
			  	label: '尊龙'
			   }]
			 }]
		}
	},
	methods:{
		// 提交评分
		async commitEdit(){
			console.log(this.$refs.myCascader.getCheckedNodes()[0].pathLabels[0]);
			console.log(this.$refs.myCascader.getCheckedNodes()[0].pathLabels[1]);
			console.log(this.value[0]);
			console.log(this.value[1]);
			console.log((parseFloat(this.valueA1)+parseFloat(this.valueA2)+parseFloat(this.valueA3)+parseFloat(this.valueA4))/parseInt('4'));
		
			let res = await this.$Http.addSelection(
				{
					markItem : 3,
					judgedId : this.value[1],
					judgedName : this.$refs.myCascader.getCheckedNodes()[0].pathLabels[1],
					departmentName  : this.$refs.myCascader.getCheckedNodes()[0].pathLabels[0],
					totalScore : (parseFloat(this.valueA1)+parseFloat(this.valueA2)+parseFloat(this.valueA3)+parseFloat(this.valueA4))/parseInt('4')
				},
			    true
			);
			console.log(res);
			console.log(res.status);
			if (res.status == 0){
				this.$message.success(`新增成功`);
			}else{
				this.$message.error(res.msg);
			}
		}
	},
	components:{  /* 前面的组件名称不能和HTML标签一样*/
    'v-rate':rate    //挂载RATE组件
  }
}

</script>
